﻿<%--














                    “Logic will get you from A to B. Imagination will take you everywhere."
                                                                     Albert Einstein.

































 


























































































































--%>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="StartTest.aspx.cs" Inherits="StartTest" MasterPageFile="Assessment.master" %>
<%@ OutputCache Location="None" %>

    
<%@ Import Namespace="EfficientLab.Elr.Common" %>
<%@ Import Namespace="EfficientLab.Elr.LocalizationPack" %>




<asp:Content ID="Content1" ContentPlaceHolderID="placeHolderGlobalLinks" runat="server">

<script type="text/javascript">

function OnTestLoaded()
{
    var globalTestButtons = document.getElementById("spanGlobalTestButtons");
    if (globalTestButtons != null)
        globalTestButtons.style.display = "inline";
        
}



function OnTestPassed()
{
    var globalTestButtons = document.getElementById("spanGlobalTestButtons");
    if (globalTestButtons != null)
        globalTestButtons.style.display = "none";
}

    
</script>
<span style="display:none;" id="spanGlobalTestButtons">
    
    <span class="ms-SPLink">
        <a href="#" onclick="appPointer.MarkedItemsOnly()" title="<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_ShowMarkedQuestionsOnlyButtonText %>">
            <asp:Literal ID="Literal1" runat="server" EnableViewState="false" Text="<%$Resources:EfficientElr_UIStrings, Forms_QTI_StartTest_ShowMarkedQuestionsOnlyDescription %>"></asp:Literal>
        </a>
    </span>
    
    |
    
    <span class="ms-SPLink">
    <a href="#" onclick="appPointer.ShowTest();">
        <asp:Literal ID="Literal2" runat="server" EnableViewState="false" Text="<%$Resources:EfficientElr_UIStrings, Forms_QTI_StartTest_ShowQuestionList %>"></asp:Literal>
    </a>
    </span>
    
    |
    <span class="ms-SPLink">
    <a href="#" onclick="appPointer.Finish(true)">
        <asp:Literal ID="Literal3" runat="server" EnableViewState="false" Text="<%$Resources:EfficientElr_UIStrings, Forms_QTI_StartTest_FinishAssessment %>"></asp:Literal>
    </a>       
    </span>
    
</span>       

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="placeHolderPageGlobalTitle" runat="server">

  <%= Assignment.QTIAssignment.Title %>
    
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="placeHolderPageTitle" runat="server">

  <%= EfficientLab.Elr.SharePointServices.Facade.Sharepoint.Instance.PrincipalProvider.GetCurrentUserInfo().DisplayName %> : <%= Assignment.QTIAssignment.Title %>

</asp:Content>


<asp:Content ID="Content4" ContentPlaceHolderID="placeHolderHead" runat="server">

<script type="text/javascript">

    var AdsPlayer_FinishTestConfirmText = "<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_AdsPlayer_FinishTestConfirmText %>";
    var AdsPlayer_MarkedQuestionsNotFound = "<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_AdsPlayer_MarkedQuestionsNotFound %>";
    var AutoSaveTimer_SavedSuccessfully = "<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_AutoSaveTimer_SavedSuccessfully %>";
    var AutoSaveTimer_SavePostponed = "<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_AutoSaveTimer_SavePostponed %>";
    var AutoSaveTimer_Secs = "<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_AutoSaveTimer_Secs %>";
    var QTICommon_QuestionRenderingError = "<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_QTICommon_QuestionRenderingError %>";
    var ChoiceInteraction_QuestionRenderingError = QTICommon_QuestionRenderingError;

    var ERR_UNSUPPORTABLEBROWSER = "<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_UnsupportedBrowser %>";
    var ERR_TESTISEMPTY = "<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_EmptyTest %>";
    var ERR_INIT = "<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_ImportTestError %>";
    var ERR_UNKNOWN = "<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_UnknownError %>";

    var ReportManager_ProcessingPanelTitle = "<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_ReportManager_ProcessingPanelTitle %>";
    var ReportManager_ProcessingPanelBody = "<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_ReportManager_ProcessingPanelBody %>";

    var ServerManager_CannotConnectToServerErrorTitle = "<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_ServerManager_CannotConnectToServerErrorTitle %>";
    var ServerManager_CannotReadServerResponse = "<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_ServerManager_CannotReadServerResponse %>";
    var ServerManager_InvalidTestFormat = "<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_ServerManager_InvalidTestFormat %>";
    var ServerManager_UnknownError = "<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_ServerManager_UnknownError %>";
    var ServerManager_NoConnectionError = "<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_ServerManager_NoConnectionError %>";

    var Timer_TimoutMessageText = "<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_Timer_TimoutMessageText %>";
    var Timer_TimeLeft = "<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_Timer_TimeLeft %>";
    
    
    var unBlur = false;
    var blurSeconds = null;
    var blurMinutes = null;
    var blurHours = null;
    var blurCount = 0;    
    var firstBlurOnMozillaAlreadyHasBeen = false;
    var strictControl = <%= Assignment.Assignment.StrictControl.ToString().ToLower() %>;
    var wasBlur = false;
    
    function LogMsg(message)
    {   
        //spanLog.innerHTML += message + "<br />";
    }
    
    window.onblur=function()
    {   
        if (strictControl)
        {
            LogMsg("window.onblur");
        
            wasBlur = true;
            var now = new Date();
            blurSeconds = now.getSeconds();
            blurMinutes = now.getMinutes();
            blurHours = now.getHours(); 
        }    
    }
    
    function SetUnBlur()
    {
        if (strictControl)
        {
            LogMsg("SetUnBlur");
            unBlur = true;
            ClearBlur();
        }    
    }
    
    function ClearBlur()
    {
        if (strictControl)
        {
            LogMsg("ClearBlur");
            
            wasBlur = false;
            blurSeconds = null;
            blurMinutes = null;
            blurHours = null;
        
            window.setTimeout("wasBlur = false;blurSeconds = null;blurMinutes = null;blurHours = null;", 1000);                // так как может очистить при воде в текст бокс, а потом сработать onblur у документа. в общем на всякий пожарный это.             
        }
    }
    
    function UnSetUnBlur()
    { 
        if (strictControl)
        {
            LogMsg("UnSetUnBlur");
            window.setTimeout("unBlur = false;", 2000);
        }
    }
    
    function TurnOffStrictControl()
    {
        strictControl = false;
    }
    
    function PressNextOnEnter(event)
    {
         var holder;
         //IE uses this
         if(window.event){
                holder=window.event.keyCode;
         }
         //FF uses this
         else{
                holder=event.which;
         }
          
         if (holder == 13)
         {
            appPointer.Next();
         }
    }

    window.onfocus = function()
    {   
        if (strictControl)
        {
            LogMsg("window.onfocus");
            LogMsg("blurCount = " + blurCount);
            LogMsg("wasBlur = " + wasBlur);
            LogMsg("unBlur = " + unBlur);
            
            if (wasBlur)
            {            
               if (blurCount == 1)
               {                
                    var now = new Date();            
                    
                    var blurTime = (now.getHours()*3600 + now.getMinutes()*60 + now.getSeconds() - ( blurHours*3600 + blurMinutes*60 + blurSeconds ));                            
                    
                    if (blurTime > 15)
                    {   
                        blurCount = blurCount + 1;          
                        alert("<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_OnBlurTestWillBeFinishWarning %>");                    
                        appPointer.Finish(false);                       
                    }                
                    
                    return;                
                }            
          
                if (blurCount == 0)
                {               
                    // то есть если ещё ни разу не просекли, но при этом уже не первый раз терялся фокус ввода и мы можем сказать - на сколько он терялся
                
                    if (!unBlur)         
                    {                
                        if (blurSeconds != null)  // если просекли, что фокус ввода терялся
                        {
                            if (isMozilla && !firstBlurOnMozillaAlreadyHasBeen)
                            {
                                firstBlurOnMozillaAlreadyHasBeen = true;
                                return;
                            }
                            
                            blurCount = blurCount + 1;
                            alert("<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_OnFirstBlurWarning %>");                                
                        }
                    }
                    else    
                    {                   
                   
                        var now = new Date();            
                        
                        var blurTime = (now.getHours()*3600 + now.getMinutes()*60 + now.getSeconds() - ( blurHours*3600 + blurMinutes*60 + blurSeconds ));                            
                        
                        if (blurTime > 15)
                        {   
                            blurCount = blurCount + 1;
                            alert("<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_OnFirstBlurWarning %>");        
                        }
                    
                    }                
                }
            }
        }    
    }


</script>
    
    <SharePoint:CssLink ID="CssLink1" runat="server" />
    <SharePoint:Theme ID="Theme1" runat="server" />


    <link rel="stylesheet" type="text/css" href="StyleSheet.css" />    
    
    <elr:JScriptLink ID="JScriptLink1" runat="server" Src="../js/core.js" />
    
    <elr:JScriptLink ID="JScriptLink2" runat="server" Src="JScript/JSResources.js" />

    <elr:JScriptLink ID="JScriptLink3" runat="server" Src="JScript/SafeObjectCreate.js" />

    <elr:JScriptLink ID="JScriptLink4" runat="server" Src="JScript/ServerManager.js" />

    <elr:JScriptLink ID="JScriptLink5" runat="server" Src="JScript/Other.js" />

    <elr:JScriptLink ID="JScriptLink6" runat="server" Src="JScript/ChoiceInteraction.js" />

    <elr:JScriptLink ID="JScriptLink7" runat="server" Src="JScript/AdsPlayer.js" />

    <elr:JScriptLink ID="JScriptLink8" runat="server" Src="JScript/Item.js" />

    <elr:JScriptLink ID="JScriptLink9" runat="server" Src="JScript/Timer.js" />

    <elr:JScriptLink ID="JScriptLink10" runat="server" Src="JScript/ReportManager.js" />

    <elr:JScriptLink ID="JScriptLink11" runat="server" Src="JScript/AutoSaveTimer.js" />

    <elr:JScriptLink ID="JScriptLink12" runat="server" Src="JScript/Init.js" />

    <elr:JScriptLink ID="JScriptLink13" runat="server" Src="JScript/OrderInteraction.js" />

    <elr:JScriptLink ID="JScriptLink14" runat="server" Src="JScript/AssociateInteraction.js" />

    <elr:JScriptLink ID="JScriptLink15" runat="server" Src="JScript/ExtendedTextInteraction.js" />

    <elr:JScriptLink ID="JScriptLink16" runat="server" Src="JScript/TextEntryInteraction.js" />
    
    <base target="_self" />
    
</asp:Content>


<asp:Content ID="Content11" ContentPlaceHolderID="placeHolderBodyOnKeyDown" runat="server">
PressNextOnEnter(event);
</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="placeHolderBodyOnLoad" runat="server">
Init();
</asp:Content>

<asp:Content ID="Content6" ContentPlaceHolderID="placeHolderOnUnload" runat="server">
return OnClose();
</asp:Content>

<asp:Content ID="Content7" ContentPlaceHolderID="placeHolderBodyOnCopy" runat="server">
return false;
</asp:Content>

<asp:Content ID="Content8" ContentPlaceHolderID="placeHolderBodyOnBeforeUnLoad" runat="server">
return CheckOnExit();
</asp:Content>


<asp:Content ID="Content9" ContentPlaceHolderID="placeHolderPageEnd" runat="server">

<script type="text/javascript">

var assignmentId = <%= RequestHelper.LearnerAssignmentId.Value %>;
var forceToExit = false;

function CancelLoad()
{
    forceToExit = true;    
    if (xmlhttp != null)
        xmlhttp.abort();
    window.close();
}

function CheckOnExit()
{
    if (forceToExit)
        return;        
    if (appPointer == null)
        return;        
    if (!appPointer.finished)
    {
        if (strictControl)
            return "<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_OnCloseTestWillBeFinishWarning %>";
        else
            return "<%=UIStringsManager.HttpContextInstance.Forms_QTI_StartTest_AnswersWillBeDeletedWarning %>";
    }
    return;
}

</script>

</asp:Content>

<asp:Content ID="Content10" ContentPlaceHolderID="placeHolderMain" runat="server">
<div>
<span id="spanLog"></span>
    <div class="CloseButton" style="width: 810px; text-align: right; margin-top:10px; margin-bottom: 5px; display:none;">
        <input type="button" onclick="window.close();" value="<%=UIStringsManager.HttpContextInstance.Common_Close %>" class="ms-buttonHeightWidth" />
    </div>
    
       <table width="100%">
            <tr>
                <td>
                    <div id="lblNetworkError" style="overflow: auto; color:Red" class="ms-vb">
                    </div>
                </td>
            </tr>
            <tr>
                <td class="generalText" align="right">
                    <div id="timerFasade">
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <tbody id="tBodyWait">
                        <tr>
                            <td>
                                <table cellpadding="0" cellspacing="0" width="100%">
                                    <tr>
                                        <td style="padding-top: 0px; padding-left: 20px; padding-right: 20px;">
                                            <img src="..\images\progress.gif" />
                                        </td>
                                        <td width="100%" style="padding-bottom: 15px">
                                            <span id="spanWaitTitle" class="ms-sectionheader">
                                                <asp:Literal ID="Literal4" runat="server" EnableViewState="false" 
                                                    Text="<%$Resources:EfficientElr_UIStrings, Forms_QTI_StartTest_Loading %>"></asp:Literal>
                                            </span>
                                            <br />
                                             <span id="spanWaitDescription" class="ms-descriptiontext" style="height:40px;">
                                                <asp:Literal ID="Literal5" runat="server" EnableViewState="false"
                                                    Text="<%$Resources:EfficientElr_UIStrings, Forms_QTI_StartTest_LoadingMessage %>"></asp:Literal>
                                             
                                            </span>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </tbody>
                </td>
            </tr>
            <tr>
                <td>
                    <div id="itemFasade" style="overflow: auto;">
                    </div>
                    <asp:Label runat="server" ID="lblAssignmentId" Style="display: none"></asp:Label>
                    <asp:Label runat="server" ID="lblStartTime" Style="display: none"></asp:Label>
                </td>
            </tr>
        </table>
    <div class="CloseButton" style="width: 810px; text-align: right; margin-bottom: 5px; display:none;">
        <input type="button" onclick="window.close();" value="<%=UIStringsManager.HttpContextInstance.Common_Close %>" class="ms-buttonHeightWidth" />
    </div>
</div>


</asp:Content> 
